﻿using Hvam.SharePoint.Search.Query.Site.Models;

namespace Hvam.SharePoint.Search.Query.Site.QuerySteps
{
    internal class WriteQueryStep : SiteSearchQueryStep
    {
        public override SiteSearchQuery Process(SiteSearchQuery query)
        {
            if (query.RequestedProperties.Contains("write") &&
                !query.RequestedFields.ContainsKey("modified") &&
                query.AvailableFields.ContainsKey("modified"))
            {
                var field = query.AvailableFields["modified"];
                query.RequestedFields.Add(field.InternalName, field);
            }

            return query;
        }
    }
}
